package com.magic.item.mapper;

import com.magic.item.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * Created by zhuqin on 2021/1/6
 */
public interface BrandMapper extends Mapper<Brand> {
    @Insert("INSERT INTO tb_category_brand (category_id, brand_id) VALUES (#{cid},#{bid})")
    void insertCategoryBrand(@Param("cid") Long cid, @Param("bid") Long bid);
    @Select("select * from tb_brand where id = #{bid}")
    List<Brand> selectUpdateBrand(Long bid);
    @Select("select category_id from tb_category_brand where brand_id = #{bid}")
    List<Long> selectCategoryId(Long bid);
    @Delete("delete from tb_category_brand where brand_id = #{id}")
    void deleteCategoryId(Long id);
    @Delete("delete from tb_brand where id = #{bid}")
    void deleteBrand(Long bid);
    @Select("SELECT * FROM tb_brand a INNER JOIN tb_category_brand b on a.id = b.brand_id where b.category_id = #{cid}")
    List<Brand> selectBrandByCid(Long cid);
}
